package com.sxg.convert;

import com.sxg.entity.SxgAddressEntity;
import com.sxg.entity.SxgCategoryEntity;
import com.sxg.entity.SxgCommentEntity;
import com.sxg.vo.req.AddressSaveReqVo;
import com.sxg.vo.resp.CategoryRespVo;
import com.sxg.vo.resp.CommentRespVo;

//生成的自动转换方法
public class ConvertUtils {

    public static CategoryRespVo toCategoryRespVo(SxgCategoryEntity sxgCategoryEntity) {
        if (sxgCategoryEntity == null) {
            return null;
        }
        CategoryRespVo categoryRespVo = new CategoryRespVo();
        categoryRespVo.setId(sxgCategoryEntity.getId());
        categoryRespVo.setName(sxgCategoryEntity.getName());
        categoryRespVo.setParentCid(sxgCategoryEntity.getParentCid());
        categoryRespVo.setLevel(sxgCategoryEntity.getLevel());
        categoryRespVo.setShowStatus(sxgCategoryEntity.getShowStatus());
        categoryRespVo.setSort(sxgCategoryEntity.getSort());
        categoryRespVo.setIcon(sxgCategoryEntity.getIcon());
        categoryRespVo.setProductCount(sxgCategoryEntity.getProductCount());

        // Not mapped CategoryRespVo fields:
        // categoryChild
        return categoryRespVo;
    }


    public static CommentRespVo toCommentRespVo(SxgCommentEntity sxgCommentEntity) {
        if (sxgCommentEntity == null) {
            return null;
        }
        CommentRespVo commentRespVo = new CommentRespVo();
        commentRespVo.setId(sxgCommentEntity.getId());
        commentRespVo.setContent(sxgCommentEntity.getContent());
        commentRespVo.setImages(sxgCommentEntity.getImages());
        commentRespVo.setUserId(sxgCommentEntity.getUserId());
        commentRespVo.setUserNickname(sxgCommentEntity.getUserNickname());
        commentRespVo.setUserAvatar(sxgCommentEntity.getUserAvatar());
        commentRespVo.setGoodsId(sxgCommentEntity.getGoodsId());
        commentRespVo.setTopCommentId(sxgCommentEntity.getTopCommentId());
        commentRespVo.setParentId(sxgCommentEntity.getParentId());
        commentRespVo.setParentNickname(sxgCommentEntity.getParentNickname());
        commentRespVo.setParentAvatar(sxgCommentEntity.getParentAvatar());
        commentRespVo.setCreateTime(sxgCommentEntity.getCreateTime());

        return commentRespVo;
    }


    public static SxgAddressEntity toSxgAddressEntity(AddressSaveReqVo vo) {

        SxgAddressEntity sxgAddressEntity = new SxgAddressEntity();
        sxgAddressEntity.setUserId(vo.getUserId());
        sxgAddressEntity.setCountry(vo.getCountry());
        sxgAddressEntity.setPhone(vo.getPhone());
        sxgAddressEntity.setName(vo.getName());
        sxgAddressEntity.setProvince(vo.getProvince());
        sxgAddressEntity.setCity(vo.getCity());
        sxgAddressEntity.setIsDefault(vo.getIsDefault());
        sxgAddressEntity.setDetail(vo.getDetail());

        return sxgAddressEntity;
    }


}
